#include <iostream>
#include <thread>
#include <future>

void Add(int x,int y,std::promise<int>& prom)
{
    std::cout << "加法" << std::endl;
    //std::this_thread::sleep_for(std::chrono::seconds(5));
    // 设立了这个值就立马返回回去。
    prom.set_value(x + y);
    std::this_thread::sleep_for(std::chrono::seconds(5));
    return ;
}

int main()
{
    std::promise<int> prom;

    std::thread th(Add,11,13,std::ref(prom));

    std::future<int> fu = prom.get_future();

    int ret = fu.get();

    std::cout << "sum:" << ret << std::endl;

    th.join();

    return 0;
}